/***************************************************************************
创建者：华磊
 开始时间：         : 2020.11.10
 copyright            : (C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************
 *   新建程序文件视窗
*                                                                         *
 ***************************************************************************/
#include "newfileview.h"
#include "ui_newfileview.h"
//#include <QDebug>

NewFileView::NewFileView(int styleId,QWidget *parent):
        QDialog(parent),
        ui(new Ui::NewFileView)
{
    ui->setupUi(this);

    setGeometry(70,128,460,595);
    initialDisplayStyle(styleId);
    //this->setWindowTitle("newFile");

    newFileName = "";
    newFileVersion = "";
    newFileOwner = "";
    newFileNote = "";

    ui->ConfirmBtn->setText(tr("确认"));

    //ui->FileName->setEnabled(false);
}

NewFileView::~NewFileView()
{
    delete ui;
}

void NewFileView::initialDisplayStyle(int styleId)
{
    switch (styleId) {
    case 1:
        this->setGeometry(0,0,600,450);
        ui->widget->setGeometry(20,0,550,400);
        ui->ConfirmBtn->setGeometry(240,350,60,40);
        ui->cancel_Btn->setGeometry(310,350,60,40);
        break;
    default:
        break;
    }
}

void NewFileView::clearLineView()
{
    ui->FileName->setText("");
    ui->Version->setText("");
    ui->Owner->setText("");
    ui->Note->setText("");
}

void NewFileView::changeLanguage()
{
    ui->retranslateUi(this);
}

void NewFileView::on_ConfirmBtn_clicked()
{
    getViewInput();

    //qDebug() << "newFileName: " << newFileName;
    //qDebug() << "newFileVersion: " << newFileVersion;
    //qDebug() << "newFileOwner: " << newFileOwner;
    //qDebug() << "newFileNote: " << newFileNote;

    emit confirmNewFile();
    this->close();
}

void NewFileView::getViewInput()
{
    newFileName = ui->FileName->text();
    newFileVersion = ui->Version->text();
    newFileOwner = ui->Owner->text();
    newFileNote = ui->Note->toPlainText();
}

void NewFileView::on_cancel_Btn_clicked()
{
    this->close();
}
